package com.lyshop.jinxiang.adapters;

import android.content.Context;
import android.graphics.Paint;
import android.widget.TextView;

import com.lyshop.jinxiang.R;
import com.lyshop.jinxiang.base.BaseRVAdapter;
import com.lyshop.jinxiang.base.BaseRVHolder;
import com.lyshop.jinxiang.bean.IntegralTicketBean;
import com.lyshop.jinxiang.bean.UserInfoBean;
import com.lyshop.jinxiang.utils.DataUtils;

import java.util.List;

public class PointsMallAdapter extends BaseRVAdapter {
    public PointsMallAdapter(Context context, List list) {
        super(context, list);
    }

    @Override
    public int onCreateViewLayoutID(int viewType) {
        return R.layout.item_points_mall;
    }

    @Override
    public void onBindView(BaseRVHolder holder, int position) {
        IntegralTicketBean bean = ( IntegralTicketBean)mList.get(position);
        TextView facevalue_number = holder.getViewHolder().get(R.id.facevalue_number);
        TextView integral_number = holder.getViewHolder().get(R.id.integral_number_org);
        TextView cur_integral_number = holder.getViewHolder().get(R.id.integral_number_cur);
        TextView ticket_name = holder.getViewHolder().get(R.id.ticket_name);

        facevalue_number.setText(bean.getMoney()+"");
        ticket_name.setText(bean.getName());
        UserInfoBean userInfoBean =  DataUtils.getUserInfo(mContext);
        if(userInfoBean.discount == 10){
            cur_integral_number.setText(bean.getNeed_integral()+"");
            integral_number.setText("");
        }else{
            integral_number.setText(bean.getNeed_integral()+"");
            int a = (int) (Double.valueOf(bean.getNeed_integral())* userInfoBean.discount);
            cur_integral_number.setText(a/10 + "");
            integral_number.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
        }
    }
}
